"""
精灵测试
"""
from Player import Player

import pygame

# 游戏初始化
pygame.init()

# 窗口的宽度和高度
WIDTH = 360
HEIGHT = 480

# 获得屏幕对象
screen = pygame.display.set_mode((WIDTH, HEIGHT))

# 设置窗口标题
pygame.display.set_caption("植物大战僵尸")

# 游戏运行状态
running = True

# Colors (R, G, B)
BLACK = (0, 0, 0)
WHITE = (255, 255, 0)
RED = (255, 0, 0)
GREEN = (0, 255, 0)
BLUE = (0, 0, 255)

# 帧率
FPS = 30
# 创建clock对象
clock = pygame.time.Clock()

# 创建精灵数组
all_sprites = pygame.sprite.Group()
# 创建精灵对象
player = Player()
# 将精灵对象添加到精灵数组中
all_sprites.add(player)

# 游戏运行循环
while running:

    # 设置帧率
    clock.tick(FPS)

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    # 精灵进行更新
    all_sprites.update()

    # 双缓存，先在内存中绘制
    screen.fill(BLACK)

    # 画出所有精灵对象
    all_sprites.draw(screen)

    pygame.display.flip()